"""
    全量字段校验综合案例
"""
import pytest
import jsonschema

from api.ihrm_login_api import IhrmLoginApi


class TestIhrmLogin:


    def test_login(self):
        # 登录
        req_data = {
           "mobile": "13800000002",
           "password": "929itheima.CN032@.20250615"
                    }
        resp = IhrmLoginApi.login(req_data)
        print(resp.json())
        # 断言
        # assert_login(status_code, code, success, message, resp)

        # 用全量字段校验代替断言
        # 校验规则
        schema = {
            "type":"object",
            "properties":{
                "success":{"const":True},
                "code":{"const":10000},
                "message":{"pattern":"^操作成功"},
                "data":{"type":"string"},
            },
            "required":["success","code","message","data"]
        }
        # 调用jsonschema.valicdate()来实现校验
        jsonschema.validate(instance=resp.json(),schema=schema)

